//这是我们要请求的api
import { cateList } from '../services/people';
export default {
  namespace: 'category',

  state: {
    cate: [],
  },

  effects: {
    *cate(_, { call, put }) {
      //请求api
      const response = yield call(cateList);
      //把返回的参数'payload'给下面的'cateList'
      yield put({
        type: 'cateList',
        payload: Array.isArray(response) ? response : [],
      });
    },
  },

  reducers: {
    //把返回的参数赋值给'state'里的'cate'
    cateList(state, action) {
      return {
        ...state,
        cate: action.payload,
      };
    },
  },
};
